<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('库存管理项列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                        	<input id="treeId" name="warehouseId" type="hidden" />
				            <li>    
				                <label>仓库：</label>
								<input type="text" onclick="selectDeptTree()" id="treeName" readonly="true" th:value="${dept?.deptName}" >
				            </li>
                        	<li>
                                <label>物料名称：</label>
                                <input type="text" name="mingc"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="gcgl:warehouseItem:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="gcgl:warehouseItem:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="gcgl:warehouseItem:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:warehouseItem:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gcgl:warehouseItem:remove')}]];
        var prefix = ctx + "gcgl/warehouseItem";
        
        /*部门管理-新增-选择父部门树*/
		function selectDeptTree() {
			var treeId = $("#treeId").val();
			if ($.common.isEmpty(treeId)) {
				treeId = 0;
       		}
			var options = {
				title: '选择',
				width: "380",
				url: ctx + "gcgl/warehouse/selectTypeTree/" + treeId,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "库存管理项",
                sortName: "updateat desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键'
                },
                {
                    field: 'warehouseName',
                    title: '仓库'
                },
                {
                    field: 'clbh',
                    title: '材料编号',
                    visible: false
                },
                {
                    field: 'clfl',
                    title: '材料分类',
                    visible: false
                },
                {
                    field: 'clpp',
                    title: '材料品牌'
                },
                {
                    field: 'mingc',
                    title: '物料名称'
                },
                {
                    field: 'guig',
                    title: '材料规格'
                },
                {
                    field: 'danw',
                    title: '材料单位'
                },
                {
                    field: 'kucshul',
                    title: '库存材料数量'
                },
                {
                    field: 'linglCount',
                    title: '领料数量'
                },
                {
                    field: 'feilCount',
                    title: '废料数量'
                },
                {
                    field: 'shul',
                    title: '剩余数量'
                },
                {
                    field: 'danj',
                    title: '材料单价',
                    visible: false
                },
                {
                    field: 'hsdj',
                    title: '含税单价',
                    visible: false
                },
                {
                    field: 'jine',
                    title: '物料金额',
                    visible: false
                },
                {
                    field: 'sl',
                    title: '税率',
                    visible: false
                },
                {
                    field: 'se',
                    title: '税额',
                    visible: false
                },
                {
                    field: 'jxse',
                    title: '进项税额',
                    visible: false
                },
                {
                    field: 'jshj',
                    title: '价税合计',
                    visible: false
                },
                {
                    field: 'memo',
                    title: '备注',
                    visible: false
                },
                {
                    field: 'zdjine',
                    title: '系统指导价',
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>